package com.ssd.nbgroup.web;

/**
 * Created by 刘宇飞 on 2017/5/15.
 */


import com.ssd.nbgroup.HelperClazz;
import com.ssd.nbgroup.dto.Location;
import com.ssd.nbgroup.service.LocationServiceImpl;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping
public class EmpController {
    @Autowired
    private LocationServiceImpl locationService;
    static String DEFAULT_JSON_CONTENT_TYPE = "application/json; charset=utf8";

    @ApiOperation(value = "存储坐标点", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lng", paramType = "doublue", value = "精度", dataType = "String"),
            @ApiImplicitParam(name = "lat", paramType = "doublue", value = "维度", dataType = "String")
    })
    @GetMapping("/insertLocal")
    public @ResponseBody
    boolean insertLocal(@RequestParam String lng, @RequestParam String lat) {
        boolean bl = locationService.saveLocatiion(lng, lat);
        return bl;
    }


    @ApiOperation(value = "跳转主界面", notes = "")
    @GetMapping("/index")
    public String index(Map<String, Object> map) {
        List<Location> loc = locationService.findAll();
        List<String[]> dd = new ArrayList<>();
        for (Location l : loc) {
            String[] ds = new String[]{l.getLng(), l.getLat()};
            dd.add(ds);
        }
        map.put("location", dd);
        return "/index";
    }


    @GetMapping("/head")
    public String head(Map<String, Object> map) {
        return "/head";
    }
}
